﻿Imports Microsoft.VisualBasic

Imports System.IO
Imports System.Web.UI
Imports System.Text

Public Class BasicPage
    Inherits System.Web.UI.Page
    'Public mInitPara As InitPara       'Open Connection
    Public mPagePara As PageParameter = Nothing

    Protected Overridable Sub GetCurrentPageStatus()
        mPagePara = New PageParameter(Request("QUERYSTR"))
        If mPagePara IsNot Nothing Then
            Dim returnURL As String = Request.Path.ToString()
            mPagePara.mCurrentFormStatus.PageName = GetCurrentPageName()
            mPagePara.mCurrentFormStatus("returnURL") = Server.UrlEncode(returnURL)
        End If
    End Sub

    Protected Overridable Sub GoBackToPreviousPage()
        mPagePara.mCurrentFormStatus.Clear()
        Dim strQuery As String = Convert.ToString(mPagePara.mParentFormStatus.PageName) & "?QUERYSTR=" & Server.UrlEncode(EncriptUrl.EncodeQueryString(mPagePara.ToString(PageNavigator.PREVIOUS)))
        Response.Redirect(strQuery)
    End Sub

    Private Function GetCurrentPageName() As String
        Dim strScriptName As String = Request.ServerVariables("SCRIPT_NAME").ToString()
        Return strScriptName.Substring(strScriptName.LastIndexOf("/"c) + 1)
    End Function

    'Public Sub CheckLogin()
    '    mInitPara = DirectCast(Session(Define.InitParaName), InitPara)
    '    If mInitPara Is Nothing Then
    '        Response.Redirect("../Login.aspx")
    '    End If
    'End Sub

    Public Sub CheckSession()
        If (Session(Define.InitParaName) Is Nothing) Then
            Response.Redirect("../Admin/Login.aspx")
        Else
            mPagePara = New PageParameter(Request("QUERYSTR"))
        End If
    End Sub

    Protected Overrides Sub OnLoad(ByVal e As EventArgs)
        MyBase.OnLoad(e)
    End Sub

    Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
        MyBase.Render(writer)
    End Sub
End Class